﻿package com.hotel.sampleTool;

import java.util.Calendar;
import java.util.Date;

import data.Task;

public class TaskSample extends RequestSampleData {

	//must create hotel for reference hotelId = 1
	//General : set critical < 1 hours
	//General : set warning < 3 hours
	
	@Override
	public void CreateSample() {
		CreateSample(1);
	}

	@Override
	public void CreateSample(int iteration) {
		for(int i=0;i<iteration;i++)
		{
			Task t = RandomTask();
			datastore.put(t.getEntity());
		}
	}
	
	public Task RandomTask()
	{
		//for random TaskTitle
		String[] sample = new String[] {"check room","check rest room","clear table","check tissue","change water valve","wakeup call","wakeup call","wakeup call","change room light","change room light"};
		int i = (int) Math.floor(Math.random() * sample.length);
		
		//for random roomName
		String room = "";
		if(sample[i].equals("check room") || sample[i].equals("wakeup call"))
			room = "10" + (int) Math.floor(Math.random() * 9);
		
		//for random status and dueDate
		double status = Math.random() * 100;
		Calendar dateCal = Calendar.getInstance();
		dateCal.setTime(new Date());
		if(status < 10)
			dateCal.add(Calendar.MINUTE, (int) Math.floor((Math.random() * 11)) * 5);
		else if(status < 30)
		{
			dateCal.add(Calendar.HOUR, 1);
			dateCal.add(Calendar.MINUTE, (int) Math.floor((Math.random() * 11)) * 10);
		}
		else
		{
			dateCal.add(Calendar.HOUR, 3);
			dateCal.add(Calendar.MINUTE, (int) Math.floor((Math.random() * 20)) * 5);
		}
		Date due = dateCal.getTime();
		
		//for create random task	
		Task t = new Task();
		t.setHotelId(1);
		t.setTaskTitle(sample[i]);
		t.setRoomName(room);
		t.setDue(due);
		t.setStatus("Normal");
		t.setTrash(false);
		t.setSetDue(false);
		t.setComplete(false);
		return t;
	}

}
